#include<bits/stdc++.h>
using namespace std;
struct Node {
    int in = 0;
    int out = 0;
    vector<Node*> next;
    int val;
    Node(int val):val(val){}
};
struct Graph {
    map<int, Node*> nodes;
};

class Solution {
public:
    vector<int> findOrder(int numCourses, vector<vector<int>>& prerequisites) {
        if (!prerequisites.size()) {
            vector<int> ret;
            for (int i = numCourses - 1; i >= 0; i--)
                ret.push_back(i);
            return ret;
        }

        Graph timeTable;
        for (int i = 0; i < numCourses; i++)
            timeTable.nodes[i] = new Node(i);
        for (auto i : timeTable.nodes) {
            auto cur = i;
            if()
        }
        for (auto cla : prerequisites) {
            Node* preClass = timeTable.nodes[cla[1]];
            Node* aftclass = timeTable.nodes[cla[0]];
            preClass->next.push_back(aftclass);
            preClass->out++;
            aftclass->in++;
        }
        vector<Node*> noIN;
        for (auto cla : timeTable.nodes)
            if (!cla.second->in) noIN.push_back(cla.second);
        for (int i = 0; i < noIN.size();i++) {
            for (auto course : noIN[i]->next) {
                if (--course->in == 0) noIN.push_back(course);
            }
        }
        vector<int>ret;
        for (auto val : noIN)
            ret.push_back(val->val);
        return ret;
        
    }
};
int main210() {
    vector<vector<int>>test = { {1,0} };
    Solution sol;
    vector<int> res = sol.findOrder(2,test);
    for (int cal : res) cout << cal << endl;
    return 0;
}